package com.zhanghu.backendZray.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhanghu.backendZray.mapper.PendingTaskMapper;
import com.zhanghu.backendZray.pojo.entity.PendingTask;
import com.zhanghu.backendZray.service.PendingTaskService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 待办事项 服务实现类
 * </p>
 *
 * @author zhangdong
 * @since 2024-09-01
 */
@Service
public class PendingTaskServiceImpl extends ServiceImpl<PendingTaskMapper, PendingTask> implements PendingTaskService {


    /**
     * 新增一条新用户试用三天的待办提醒事项
     *
     * @param userId
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addTrialPendingTask(Integer userId) {
        PendingTask task = new PendingTask();
        task.setUserId(userId);
        task.setType((byte) 1);
        task.setTitle("试用提醒");
        task.setContent("您是新用户，三天内免费试用。您也可以从右上角会员入口处购买，成为本站会员，获得永久使用权！");
        task.setSendStatus((byte) 0);
        task.setStatus((byte) 3);
        task.setSponsor(userId);
        save(task);
    }
}
